package recommendation;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;

public class Movie {
	private HashMap<String,MovieInfo> movie=new HashMap<String,MovieInfo>();
	static private Movie instance = new Movie();
	String filename= "recommender_system_data\\movies.dat";
	private Movie()
	{
		try {
			String content=null;
			BufferedReader bf = new BufferedReader(new FileReader(filename));
			while((content = bf.readLine())!=null) {
				String []sp = content.split("::");
				MovieInfo mi = new MovieInfo(sp[1],sp[2]);
				movie.put(sp[0], mi);
			}
			bf.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			System.out.print(filename+"文件不存在");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public static Movie getInstance()
	{
		return instance;
	}
	public MovieInfo getMovieInfo(String id)
	{
		return movie.get(id);
	}
}